﻿@model Web.ViewModels.OrderViewModel

@{
    ViewBag.Title = "Редактирование заказа";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}

<h2>Редактирование заказа</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)

    <div class="content_in"> 
         
       <table id="editorder">
                <tr>
                    <td class="editor-label">Номер заказа      @Html.HiddenFor(model => model.order.Id)</td>
                    <td class="editor-label">@Html.DisplayFor(model=>model.order.Id)</td>
                </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.OrderDate)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.OrderDate)
                   @Html.ValidationMessageFor(model => model.order.OrderDate)
               </td>
           </tr>
                           <tr>
                    <td class="editor-label">
                        @Html.LabelFor(model => model.order.FirstName)
                    </td>
                    <td class="editor-field">
                        @Html.EditorFor(model => model.order.FirstName)
                        @Html.ValidationMessageFor(model => model.order.FirstName)
                    </td>
                </tr>
                <tr>
                    <td class="editor-label">
                        @Html.LabelFor(model => model.order.LastName)
                    </td>
                    <td class="editor-field">
                        @Html.EditorFor(model => model.order.LastName)
                        @Html.ValidationMessageFor(model => model.order.LastName)
                    </td>
                </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.MiddleName)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.MiddleName)
                   @Html.ValidationMessageFor(model => model.order.MiddleName)
               </td>
           </tr>
                           <tr>
                    <td class="editor-label">
                        @Html.LabelFor(model => model.order.City)
                    </td>
                    <td class="editor-field">
                        @Html.EditorFor(model => model.order.City)
                        @Html.ValidationMessageFor(model => model.order.City)
                    </td>
                </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.State)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.State)
                   @Html.ValidationMessageFor(model => model.order.State)
               </td>
           </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.Address)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.Address)
                   @Html.ValidationMessageFor(model => model.order.Address)
               </td>
           </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.Country)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.Country)
                   @Html.ValidationMessageFor(model => model.order.Country)
               </td>
           </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.PostalCode)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.PostalCode)
                   @Html.ValidationMessageFor(model => model.order.PostalCode)
               </td>
           </tr>
           <tr>
                    <td class="editor-label">
                        @Html.LabelFor(model => model.order.Phone)
                    </td>
                    <td class="editor-field">
                        @Html.EditorFor(model => model.order.Phone)
                        @Html.ValidationMessageFor(model => model.order.Phone)
                    </td>
                </tr>
                <tr>
                    <td class="editor-label">
                        @Html.LabelFor(model => model.order.Email)
                    </td>
                    <td class="editor-field">
                        @Html.EditorFor(model => model.order.Email)
                        @Html.ValidationMessageFor(model => model.order.Email)
                    </td>
                </tr>
           <tr>
               <td class="editor-label">
                   @Html.LabelFor(model => model.order.Total)
               </td>
               <td class="editor-field">
                   @Html.EditorFor(model => model.order.Total)
                   @Html.ValidationMessageFor(model => model.order.Total)
               </td>
           </tr>
                           <tr>
                    <td class="editor-label">
                        @Html.LabelFor(model => model.order.Username)
                    </td>
                    <td class="editor-field">
                        @Html.EditorFor(model => model.order.Username)
                        @Html.ValidationMessageFor(model => model.order.Username)
                    </td>
                </tr>
                <tr>
                    <td class="editor-label">
                        Статус
                    </td>
                    <td class="editor-field">
                        @Html.DropDownListFor(model=>model.order.OrderStatusId,(SelectList)ViewBag.OrderStatusId,Model.order.OrderStatusId)
                    </td>
                </tr>
             

            </table>

        </div> 
    
    <div class="content_in">
    
        <table>
            <tr>
                <th>
                    Название
                </th>
                <th>
                    Категория
                </th>
       
                <th>
                    Упаковка (г)
                </th>
                <th>
                    Количество
                </th>
                <th>
                
                    Цена (грн)
                </th>
            </tr>

            @foreach (var item in Model.orderDetails) {
                <tr id ="row-@item.ProduceInPackageId">
                    <td>
                        @Html.DisplayFor(modelItem => item.Name)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Category)
                    </td>
        
                    <td>
                        @Html.DisplayFor(modelItem => item.Package)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Count)        
                    </td>
                    <td>
                        @String.Format("{0:0.00}", ( item.Count*item.Price))
                    </td>
    
        
                </tr>
            }
        </table>
        <p>
            @Html.ActionLink("Редактировать список  покупок","EditListOrder", new { id=Model.order.Id})
            </p>
    
        <p>
            <input type="submit" value="Сохранить" />
        </p>

        </div>
 
}

<div>
    @Html.ActionLink("К списку новых заказов", "BrowseNewOrders")<br/>
    @Html.ActionLink("К списку заказов в обработке", "BrowseOrdersInProcessing")<br/>
    @Html.ActionLink("К журналу заказов", "BrowseExecutedOrders")
</div>
